import request from "@/utils/request";

// 查询车辆信息列表
export function searchCarList(licenseNumber, page, size) {
  return request({
    url: "/car/api/v1/car/carList",
    method: "post",
    params: {
      licenseNumber: licenseNumber,
      page: page,
      size: size,
    },
  });
}

export function getCarBasicById(id) {
  return request({
    url: '/car/api/v1/car/getCarBasicById',
    method: 'post',
    params:{
      id:id
    }
  })
}

// 修改车辆基本信息
export function updateCarBasic(id,carNumber,brand,carMoney,buyTime,maxUseYear, driverId, driverName, driverPhone,status, carImageUrl, revenueMethod) {
  return request({
    url: '/car/api/v1/car/updateCarBasic',
    method: 'post',
    params:{
      id: id,
      carNumber: carNumber,
      brand: brand,
      carMoney: carMoney,
      buyTime: buyTime,
      maxUseYear: maxUseYear,
      driverId: driverId,
      driverName: driverName,
      driverPhone: driverPhone,
      status: status,
      carImageUrl: carImageUrl,
      revenueMethod: revenueMethod
    }
  })
}

// 删除车辆基本信息
export function delCarBasic(id) {
  return request({
    url: '/car/api/v1/car/delCarBasic',
    params: {
      id: id
    },
    method: 'post'
  })
}

// 根据id查询行驶证
export function getCarLicense(driverId) {
  return request({
    url: '/car/api/v1/car/getCarLicense',
    method: 'get',
    params:{
        driverId:driverId
    }
  })
}

// 修改用户
export function updateLicense(id,licenseImage) {
  return request({
    url: '/car/api/v1/car/updateLicense',
    method: 'post',
    params:{
      id:id,
      licenseImage:licenseImage
    }
  })
}

// 查询车辆年检信息列表
export function searchCarYearCheckList(licenseNumber, remark, page, size) {
    return request({
      url: "/car/api/v1/car/yearCheckList",
      method: "post",
      params: {
        licenseNumber: licenseNumber,
        remark: remark,
        page: page,
        size: size,
      },
    });
  }

  export function getCarYearCheckById(id) {
    return request({
      url: '/car/api/v1/car/getCarYearCheckById',
      method: 'post',
      params:{
        id:id
      }
    })
  }

// 修改年检信息
export function updateYearCheck(id,carNumber,cost,yearCheckTime,remark,driverNameAndPhone,driverId) {
  return request({
    url: '/car/api/v1/car/updateYearCheck',
    method: 'post',
    params:{
      id:id,
      carNumber:carNumber,
      cost:cost,
      yearCheckTime:yearCheckTime,
      remark:remark,
      driverNameAndPhone:driverNameAndPhone,
      driverId:driverId
    }
  })
}

// 年检记录
export function delYearCheck(id) {
  return request({
    url: '/car/api/v1/car/deleteYearCheck',
    params: {
      id: id
    },
    method: 'post'
  })
}

export function getCarRepairList(carNumber,repairName,page,size) {
  return request({
    url: '/car/api/v1/car/getCarRepairList',
    method: 'post',
    params:{
      carNumber:carNumber,
      repairName:repairName,
      page:page,
      size:size,
    }
  })
}

export function getRepairById(id) {
  return request({
    url: '/car/api/v1/car/getRepairById',
    method: 'post',
    params:{
      id:id
    }
  })
}

export function updateRepair(id, carNumber, driverName, driverPhone, repairName, repairPhone, repairAddress, repairCost, repairDocumentImage, applyTime, estimateTime) {
  return request({
    url: '/car/api/v1/car/updateRepair',
    method: 'post',
    params: {
      id: id,
      carNumber: carNumber,
      driverName: driverName,
      driverPhone: driverPhone,
      repairName: repairName,
      repairPhone: repairPhone,
      repairAddress: repairAddress,
      repairCost: repairCost,
      repairDocumentImage: repairDocumentImage,
      applyTime: applyTime,
      estimateTime: estimateTime
    }
  })
}

export function delRepair(id) {
  return request({
    url: '/car/api/v1/car/deleteRepair',
    params: {
      id: id
    },
    method: 'post'
  })
}

export function confirmRepair(id) {
  return request({
    url: '/car/api/v1/car/confirmRepair',
    method: 'post',
    params: {
      id: id
    }
  })
}

export function confirmYearCheck(id) {
  return request({
    url: '/car/api/v1/car/confirmYearCheck',
    method: 'post',
    params: {
      id: id
    }
  })
}

export function getCarFeeList(carNumber,revenueMethod,page,size) {
  return request({
    url: '/car/api/v1/car/getCarFeeList',
    method: 'post',
    params:{
      carNumber:carNumber,
      revenueMethod:revenueMethod,
      page:page,
      size:size,
    }
  })
}

// 查询车辆信息列表
export function searchCarByToken() {
  return request({
    url: "/car/api/v1/car/searchCarByToken",
    method: "get",
  });
}

export function newRepair(carNumber) {
  return request({
    url: '/car/api/v1/car/newRepair',
    method: 'post',
    params:{
      carNumber:carNumber
    }
  })
}

export function saveFee(carNumber,runFee,gasolineFee) {
  return request({
    url: '/car/api/v1/car/saveFee',
    method: 'post',
    params:{
      runFee:runFee,
      carNumber:carNumber,
      gasolineFee:gasolineFee,
    }
  })
}

export function getCarFee(carNumber) {
  return request({
    url: '/car/api/v1/car/getCarFee',
    method: 'post',
    params:{
      carNumber:carNumber,
    }
  })
}

export function fetchBarChartData() {
  return request({
    url: "/driver/api/v1/info/fetchBarChartData",
    method: "get",
  });
}

export function fetchPieChartData() {
  return request({
    url: "/car/api/v1/car/fetchPieChartData",
    method: "get",
  });
}

export function fetchBarChartDataFee() {
  return request({
    url: "/car/api/v1/car/fetchBarChartDataFee",
    method: "get",
  });
}

export function fetchPieChartDataState() {
  return request({
    url: "/car/api/v1/car/fetchPieChartDataState",
    method: "get",
  });
}

export function delFee(id) {
  return request({
    url: '/car/api/v1/car/deleteFee',
    params: {
      id: id
    },
    method: 'post'
  })
}